Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefined dataclasses.KW_ONLY #5826

Merged
merged 3 commits into from
Aug 1, 2021
Merged

Conversation

erictraut
Copy link
Contributor

It was previously defined as a class instance, but class instances are illegal when used within a type annotation. It needs to be a class or a type alias that refers to a class.

…s instance. Class instances are illegal to use within a type annotation.
Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I'd prefer something like class KW_ONLY: ..., since KW_ONLY is actually an instance of _KW_ONLY_TYPE at runtime, so repurposing it is a little confusing (https://github.com/python/cpython/blob/b6bde9fc42aecad5be0457198d17cfe7b481ad79/Lib/dataclasses.py#L192)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@JelleZijlstra
Copy link
Member

python/mypy#10867 wanted a similar change (cc @tgallant), so sounds like this is the right direction to take to make this feature implementable for type checkers.

There's some CI failures though; you'll probably have to add to the stubtest allowlist.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2021

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit ea4be02 into python:master Aug 1, 2021
tgallant added a commit to tgallant/mypy that referenced this pull request Aug 5, 2021
tgallant added a commit to tgallant/mypy that referenced this pull request Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants